home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mint99s / asmtab.c next >
C/C++ Source or Header  |  1992-12-23  |  32KB  |  1,179 lines

  1.  
  2. /*  A Bison parser, made from asm.y  */
  3.  
  4. #define YYBISON 1  /* Identify Bison output.  */
  5.  
  6. #define    WORD    258
  7. #define    WHITESP    259
  8. #define    EOLN    260
  9. #define    STRING    261
  10. #define    DEFINECMD    262
  11. #define    INCLUDECMD    263
  12. #define    IFDEFCMD    264
  13. #define    IFNDEFCMD    265
  14. #define    ELSECMD    266
  15. #define    ENDIFCMD    267
  16.  
  17. #line 3 "asm.y"
  18.  
  19. #define YYSTYPE char *
  20.  
  21. #include "asmtrans.h"
  22.  
  23. #ifndef YYLTYPE
  24. typedef
  25.   struct yyltype
  26.     {
  27.       int timestamp;
  28.       int first_line;
  29.       int first_column;
  30.       int last_line;
  31.       int last_column;
  32.       char *text;
  33.    }
  34.   yyltype;
  35.  
  36. #define YYLTYPE yyltype
  37. #endif
  38.  
  39. #ifndef YYSTYPE
  40. #define YYSTYPE int
  41. #endif
  42. #include <stdio.h>
  43.  
  44. #ifndef __STDC__
  45. #define const
  46. #endif
  47.  
  48.  
  49.  
  50. #define    YYFINAL        87
  51. #define    YYFLAG        -32768
  52. #define    YYNTBASE    25
  53.  
  54. #define YYTRANSLATE(x) ((unsigned)(x) <= 267 ? yytranslate[x] : 35)
  55.  
  56. static const char yytranslate[] = {     0,
  57.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  58.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  59.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  60.      2,     2,     2,     2,    15,    22,     2,     2,     2,    16,
  61.     17,    23,    18,    13,    19,     2,    24,     2,     2,     2,
  62.      2,     2,     2,     2,     2,     2,     2,    14,     2,     2,
  63.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  64.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  65.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  66.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  67.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  68.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  69.      2,     2,    20,     2,    21,     2,     2,     2,     2,     2,
  70.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  71.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  72.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  73.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  74.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  75.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  76.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  77.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  78.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  79.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  80.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  81.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  82.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  83.      6,     7,     8,     9,    10,    11,    12
  84. };
  85.  
  86. #if YYDEBUG != 0
  87. static const short yyprhs[] = {     0,
  88.      0,     1,     4,     6,     9,    12,    16,    21,    26,    33,
  89.     40,    45,    50,    53,    56,    59,    64,    68,    74,    76,
  90.     80,    82,    85,    87,    90,    94,    99,   104,   109,   114,
  91.    121,   128,   130,   134,   137,   139,   142,   144,   146,   148
  92. };
  93.  
  94. #endif
  95.  
  96. static const short yyrhs[] = {    -1,
  97.     25,    26,     0,     5,     0,    30,     5,     0,    27,     5,
  98.      0,    30,    27,     5,     0,     8,     4,     6,     5,     0,
  99.      8,     4,     3,     5,     0,     7,     4,     3,     4,     6,
  100.      5,     0,     7,     4,     3,     4,    31,     5,     0,     9,
  101.      4,     3,     5,     0,    10,     4,     3,     5,     0,    11,
  102.      5,     0,    12,     5,     0,     4,    29,     0,     4,    29,
  103.      4,    28,     0,     3,     4,    29,     0,     3,     4,    29,
  104.      4,    28,     0,    31,     0,    31,    13,    28,     0,     3,
  105.      0,     3,    14,     0,    32,     0,    15,    32,     0,    16,
  106.     32,    17,     0,    16,    32,    17,    18,     0,    19,    16,
  107.     32,    17,     0,    32,    16,    32,    17,     0,    16,    32,
  108.     17,     3,     0,    32,    16,    32,    13,    32,    17,     0,
  109.     32,    20,    32,    14,    32,    21,     0,    33,     0,    33,
  110.     34,    32,     0,    19,    32,     0,     3,     0,    22,     3,
  111.      0,    18,     0,    19,     0,    23,     0,    24,     0
  112. };
  113.  
  114. #if YYDEBUG != 0
  115. static const short yyrline[] = { 0,
  116.     22,    23,    26,    29,    30,    31,    33,    34,    35,    37,
  117.     39,    40,    41,    42,    45,    46,    49,    50,    55,    56,
  118.     60,    63,    65,    66,    67,    68,    69,    70,    71,    72,
  119.     74,    78,    79,    80,    82,    83,    86,    87,    88,    89
  120. };
  121.  
  122. static const char * const yytname[] = {   "$","error","$illegal.","WORD","WHITESP",
  123. "EOLN","STRING","DEFINECMD","INCLUDECMD","IFDEFCMD","IFNDEFCMD","ELSECMD","ENDIFCMD",
  124. "','","':'","'#'","'('","')'","'+'","'-'","'{'","'}'","'$'","'*'","'/'","input",
  125. "line","opline","ops","opcode","label","operand","basic","basexpr","op",""
  126. };
  127. #endif
  128.  
  129. static const short yyr1[] = {     0,
  130.     25,    25,    26,    26,    26,    26,    26,    26,    26,    26,
  131.     26,    26,    26,    26,    27,    27,    27,    27,    28,    28,
  132.     29,    30,    31,    31,    31,    31,    31,    31,    31,    31,
  133.     31,    32,    32,    32,    33,    33,    34,    34,    34,    34
  134. };
  135.  
  136. static const short yyr2[] = {     0,
  137.      0,     2,     1,     2,     2,     3,     4,     4,     6,     6,
  138.      4,     4,     2,     2,     2,     4,     3,     5,     1,     3,
  139.      1,     2,     1,     2,     3,     4,     4,     4,     4,     6,
  140.      6,     1,     3,     2,     1,     2,     1,     1,     1,     1
  141. };
  142.  
  143. static const short yydefact[] = {     1,
  144.      0,     0,     0,     3,     0,     0,     0,     0,     0,     0,
  145.      2,     0,     0,     0,    22,    21,    15,     0,     0,     0,
  146.      0,    13,    14,     5,     0,     4,     0,    17,     0,     0,
  147.      0,     0,     0,     0,     6,     0,    35,     0,     0,     0,
  148.      0,    16,    19,    23,    32,     0,     8,     7,    11,    12,
  149.     18,     0,    24,     0,     0,    34,    36,     0,     0,     0,
  150.     37,    38,    39,    40,     0,     0,     0,    25,     0,    20,
  151.      0,     0,    33,     9,    10,    29,    26,    27,     0,    28,
  152.      0,     0,     0,    30,    31,     0,     0
  153. };
  154.  
  155. static const short yydefgoto[] = {     1,
  156.     11,    12,    42,    17,    13,    43,    44,    45,    65
  157. };
  158.  
  159. static const short yypact[] = {-32768,
  160.     47,     1,     3,-32768,    44,    49,    56,    57,    58,    59,
  161. -32768,    60,     8,     3,-32768,-32768,    62,    64,    30,    65,
  162.     66,-32768,-32768,-32768,    67,-32768,    68,    70,    13,    71,
  163.     72,    73,    74,    75,-32768,    13,-32768,    27,    27,    15,
  164.     69,-32768,    63,   -12,    21,     4,-32768,-32768,-32768,-32768,
  165. -32768,    27,-32768,    45,    27,-32768,-32768,    13,    27,    27,
  166. -32768,-32768,-32768,-32768,    27,    76,    77,     6,    53,-32768,
  167.     25,    78,-32768,-32768,-32768,-32768,-32768,-32768,    27,-32768,
  168.     27,    79,    80,-32768,-32768,    83,-32768
  169. };
  170.  
  171. static const short yypgoto[] = {-32768,
  172. -32768,    81,   -33,    84,-32768,    38,   -38,-32768,-32768
  173. };
  174.  
  175.  
  176. #define    YYLAST        101
  177.  
  178.  
  179. static const short yytable[] = {    53,
  180.     54,    56,    51,    59,    14,    16,    37,    60,    76,    66,
  181.     25,     3,    26,    56,    15,    37,    69,    37,    38,    39,
  182.     71,    72,    40,    77,    70,    41,    73,    38,    39,    37,
  183.     55,    40,    31,    52,    41,    32,    41,    79,    61,    62,
  184.     82,    80,    83,    63,    64,    52,    86,    18,    41,     2,
  185.      3,     4,    19,     5,     6,     7,     8,     9,    10,    20,
  186.     21,    68,    22,    23,    24,    29,    30,    33,    34,    78,
  187.     14,    57,    35,    36,    46,    58,    47,    48,    49,    50,
  188.     74,    75,    87,    67,     0,     0,     0,     0,     0,     0,
  189.      0,    81,     0,    27,     0,    84,     0,    28,     0,     0,
  190.     85
  191. };
  192.  
  193. static const short yycheck[] = {    38,
  194.     39,    40,    36,    16,     4,     3,     3,    20,     3,     6,
  195.      3,     4,     5,    52,    14,     3,    55,     3,    15,    16,
  196.     59,    60,    19,    18,    58,    22,    65,    15,    16,     3,
  197.     16,    19,     3,    19,    22,     6,    22,    13,    18,    19,
  198.     79,    17,    81,    23,    24,    19,     0,     4,    22,     3,
  199.      4,     5,     4,     7,     8,     9,    10,    11,    12,     4,
  200.      4,    17,     5,     5,     5,     4,     3,     3,     3,    17,
  201.      4,     3,     5,     4,     4,    13,     5,     5,     5,     5,
  202.      5,     5,     0,    46,    -1,    -1,    -1,    -1,    -1,    -1,
  203.     -1,    14,    -1,    13,    -1,    17,    -1,    14,    -1,    -1,
  204.     21
  205. };
  206. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  207. #line 3 "bison.simple"
  208.  
  209. /* Skeleton output parser for bison,
  210.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  211.  
  212.    This program is free software; you can redistribute it and/or modify
  213.    it under the terms of the GNU General Public License as published by
  214.    the Free Software Foundation; either version 1, or (at your option)
  215.    any later version.
  216.  
  217.    This program is distributed in the hope that it will be useful,
  218.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  219.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  220.    GNU General Public License for more details.
  221.  
  222.    You should have received a copy of the GNU General Public License
  223.    along with this program; if not, write to the Free Software
  224.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  225.  
  226.  
  227. #ifndef alloca
  228. #ifdef __GNUC__
  229. #define alloca __builtin_alloca
  230. #else /* not GNU C.  */
  231. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc)
  232. #include <alloca.h>
  233. #else /* not sparc */
  234. #if defined (MSDOS) && !defined (__TURBOC__)
  235. #include <malloc.h>
  236. #else /* not MSDOS, or __TURBOC__ */
  237. #if defined(_AIX)
  238. #include <malloc.h>
  239.  #pragma alloca
  240. #endif /* not _AIX */
  241. #endif /* not MSDOS, or __TURBOC__ */
  242. #endif /* not sparc.  */
  243. #endif /* not GNU C.  */
  244. #endif /* alloca not defined.  */
  245.  
  246. /* This is the parser code that is written into each bison parser
  247.   when the %semantic_parser declaration is not specified in the grammar.
  248.   It was written by Richard Stallman by simplifying the hairy parser
  249.   used when %semantic_parser is specified.  */
  250.  
  251. /* Note: there must be only one dollar sign in this file.
  252.    It is replaced by the list of actions, each action
  253.    as one case of the switch.  */
  254.  
  255. #define yyerrok        (yyerrstatus = 0)
  256. #define yyclearin    (yychar = YYEMPTY)
  257. #define YYEMPTY        -2
  258. #define YYEOF        0
  259. #define YYACCEPT    return(0)
  260. #define YYABORT     return(1)
  261. #define YYERROR        goto yyerrlab1
  262. /* Like YYERROR except do call yyerror.
  263.    This remains here temporarily to ease the
  264.    transition to the new meaning of YYERROR, for GCC.
  265.    Once GCC version 2 has supplanted version 1, this can go.  */
  266. #define YYFAIL        goto yyerrlab
  267. #define YYRECOVERING()  (!!yyerrstatus)
  268. #define YYBACKUP(token, value) \
  269. do                                \
  270.   if (yychar == YYEMPTY && yylen == 1)                \
  271.     { yychar = (token), yylval = (value);            \
  272.       yychar1 = YYTRANSLATE (yychar);                \
  273.       YYPOPSTACK;                        \
  274.       goto yybackup;                        \
  275.     }                                \
  276.   else                                \
  277.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  278. while (0)
  279.  
  280. #define YYTERROR    1
  281. #define YYERRCODE    256
  282.  
  283. #ifndef YYPURE
  284. #define YYLEX        yylex()
  285. #endif
  286.  
  287. #ifdef YYPURE
  288. #ifdef YYLSP_NEEDED
  289. #define YYLEX        yylex(&yylval, &yylloc)
  290. #else
  291. #define YYLEX        yylex(&yylval)
  292. #endif
  293. #endif
  294.  
  295. /* If nonreentrant, generate the variables here */
  296.  
  297. #ifndef YYPURE
  298.  
  299. int    yychar;            /*  the lookahead symbol        */
  300. YYSTYPE    yylval;            /*  the semantic value of the        */
  301.                 /*  lookahead symbol            */
  302.  
  303. #ifdef YYLSP_NEEDED
  304. YYLTYPE yylloc;            /*  location data for the lookahead    */
  305.                 /*  symbol                */
  306. #endif
  307.  
  308. int yynerrs;            /*  number of parse errors so far       */
  309. #endif  /* not YYPURE */
  310.  
  311. #if YYDEBUG != 0
  312. int yydebug;            /*  nonzero means print parse trace    */
  313. /* Since this is uninitialized, it does not stop multiple parsers
  314.    from coexisting.  */
  315. #endif
  316.  
  317. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  318.  
  319. #ifndef    YYINITDEPTH
  320. #define YYINITDEPTH 200
  321. #endif
  322.  
  323. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  324.     (effective only if the built-in stack extension method is used).  */
  325.  
  326. #if YYMAXDEPTH == 0
  327. #undef YYMAXDEPTH
  328. #endif
  329.  
  330. #ifndef YYMAXDEPTH
  331. #define YYMAXDEPTH 10000
  332. #endif
  333.  
  334. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  335. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  336. #else                /* not GNU C or C++ */
  337. #ifndef __cplusplus
  338.  
  339. /* This is the most reliable way to avoid incompatibilities
  340.    in available built-in functions on various systems.  */
  341. static void
  342. __yy_bcopy (from, to, count)
  343.      char *from;
  344.      char *to;
  345.      int count;
  346. {
  347.   register char *f = from;
  348.   register char *t = to;
  349.   register int i = count;
  350.  
  351.   while (i-- > 0)
  352.     *t++ = *f++;
  353. }
  354.  
  355. #else /* __cplusplus */
  356.  
  357. /* This is the most reliable way to avoid incompatibilities
  358.    in available built-in functions on various systems.  */
  359. static void
  360. __yy_bcopy (char *from, char *to, int count)
  361. {
  362.   register char *f = from;
  363.   register char *t = to;
  364.   register int i = count;
  365.  
  366.   while (i-- > 0)
  367.     *t++ = *f++;
  368. }
  369.  
  370. #endif
  371. #endif
  372.  
  373. #line 169 "bison.simple"
  374. int
  375. yyparse()
  376. {
  377.   register int yystate;
  378.   register int yyn;
  379.   register short *yyssp;
  380.   register YYSTYPE *yyvsp;
  381.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  382.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  383.  
  384.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  385.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  386.  
  387.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  388.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  389.  
  390. #ifdef YYLSP_NEEDED
  391.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  392.   YYLTYPE *yyls = yylsa;
  393.   YYLTYPE *yylsp;
  394.  
  395. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  396. #else
  397. #define YYPOPSTACK   (yyvsp--, yyssp--)
  398. #endif
  399.  
  400.   int yystacksize = YYINITDEPTH;
  401.  
  402. #ifdef YYPURE
  403.   int yychar;
  404.   YYSTYPE yylval;
  405.   int yynerrs;
  406. #ifdef YYLSP_NEEDED
  407.   YYLTYPE yylloc;
  408. #endif
  409. #endif
  410.  
  411.   YYSTYPE yyval;        /*  the variable used to return        */
  412.                 /*  semantic values from the action    */
  413.                 /*  routines                */
  414.  
  415.   int yylen;
  416.  
  417. #if YYDEBUG != 0
  418.   if (yydebug)
  419.     fprintf(stderr, "Starting parse\n");
  420. #endif
  421.  
  422.   yystate = 0;
  423.   yyerrstatus = 0;
  424.   yynerrs = 0;
  425.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  426.  
  427.   /* Initialize stack pointers.
  428.      Waste one element of value and location stack
  429.      so that they stay on the same level as the state stack.
  430.      The wasted elements are never initialized.  */
  431.  
  432.   yyssp = yyss - 1;
  433.   yyvsp = yyvs;
  434. #ifdef YYLSP_NEEDED
  435.   yylsp = yyls;
  436. #endif
  437.  
  438. /* Push a new state, which is found in  yystate  .  */
  439. /* In all cases, when you get here, the value and location stacks
  440.    have just been pushed. so pushing a state here evens the stacks.  */
  441. yynewstate:
  442.  
  443.   *++yyssp = yystate;
  444.  
  445.   if (yyssp >= yyss + yystacksize - 1)
  446.     {
  447.       /* Give user a chance to reallocate the stack */
  448.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  449.       YYSTYPE *yyvs1 = yyvs;
  450.       short *yyss1 = yyss;
  451. #ifdef YYLSP_NEEDED
  452.       YYLTYPE *yyls1 = yyls;
  453. #endif
  454.  
  455.       /* Get the current used size of the three stacks, in elements.  */
  456.       int size = yyssp - yyss + 1;
  457.  
  458. #ifdef yyoverflow
  459.       /* Each stack pointer address is followed by the size of
  460.      the data in use in that stack, in bytes.  */
  461.       yyoverflow("parser stack overflow",
  462.          &yyss1, size * sizeof (*yyssp),
  463.          &yyvs1, size * sizeof (*yyvsp),
  464. #ifdef YYLSP_NEEDED
  465.          &yyls1, size * sizeof (*yylsp),
  466. #endif
  467.          &yystacksize);
  468.  
  469.       yyss = yyss1; yyvs = yyvs1;
  470. #ifdef YYLSP_NEEDED
  471.       yyls = yyls1;
  472. #endif
  473. #else /* no yyoverflow */
  474.       /* Extend the stack our own way.  */
  475.       if (yystacksize >= YYMAXDEPTH)
  476.     {
  477.       yyerror("parser stack overflow");
  478.       return 2;
  479.     }
  480.       yystacksize *= 2;
  481.       if (yystacksize > YYMAXDEPTH)
  482.     yystacksize = YYMAXDEPTH;
  483.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  484.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  485.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  486.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  487. #ifdef YYLSP_NEEDED
  488.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  489.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  490. #endif
  491. #endif /* no yyoverflow */
  492.  
  493.       yyssp = yyss + size - 1;
  494.       yyvsp = yyvs + size - 1;
  495. #ifdef YYLSP_NEEDED
  496.       yylsp = yyls + size - 1;
  497. #endif
  498.  
  499. #if YYDEBUG != 0
  500.       if (yydebug)
  501.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  502. #endif
  503.  
  504.       if (yyssp >= yyss + yystacksize - 1)
  505.     YYABORT;
  506.     }
  507.  
  508. #if YYDEBUG != 0
  509.   if (yydebug)
  510.     fprintf(stderr, "Entering state %d\n", yystate);
  511. #endif
  512.  
  513.   goto yybackup;
  514.  yybackup:
  515.  
  516. /* Do appropriate processing given the current state.  */
  517. /* Read a lookahead token if we need one and don't already have one.  */
  518. /* yyresume: */
  519.  
  520.   /* First try to decide what to do without reference to lookahead token.  */
  521.  
  522.   yyn = yypact[yystate];
  523.   if (yyn == YYFLAG)
  524.     goto yydefault;
  525.  
  526.   /* Not known => get a lookahead token if don't already have one.  */
  527.  
  528.   /* yychar is either YYEMPTY or YYEOF
  529.      or a valid token in external form.  */
  530.  
  531.   if (yychar == YYEMPTY)
  532.     {
  533. #if YYDEBUG != 0
  534.       if (yydebug)
  535.     fprintf(stderr, "Reading a token: ");
  536. #endif
  537.       yychar = YYLEX;
  538.     }
  539.  
  540.   /* Convert token to internal form (in yychar1) for indexing tables with */
  541.  
  542.   if (yychar <= 0)        /* This means end of input. */
  543.     {
  544.       yychar1 = 0;
  545.       yychar = YYEOF;        /* Don't call YYLEX any more */
  546.  
  547. #if YYDEBUG != 0
  548.       if (yydebug)
  549.     fprintf(stderr, "Now at end of input.\n");
  550. #endif
  551.     }
  552.   else
  553.     {
  554.       yychar1 = YYTRANSLATE(yychar);
  555.  
  556. #if YYDEBUG != 0
  557.       if (yydebug)
  558.     {
  559.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  560.       /* Give the individual parser a way to print the precise meaning
  561.          of a token, for further debugging info.  */
  562. #ifdef YYPRINT
  563.       YYPRINT (stderr, yychar, yylval);
  564. #endif
  565.       fprintf (stderr, ")\n");
  566.     }
  567. #endif
  568.     }
  569.  
  570.   yyn += yychar1;
  571.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  572.     goto yydefault;
  573.  
  574.   yyn = yytable[yyn];
  575.  
  576.   /* yyn is what to do for this token type in this state.
  577.      Negative => reduce, -yyn is rule number.
  578.      Positive => shift, yyn is new state.
  579.        New state is final state => don't bother to shift,
  580.        just return success.
  581.      0, or most negative number => error.  */
  582.  
  583.   if (yyn < 0)
  584.     {
  585.       if (yyn == YYFLAG)
  586.     goto yyerrlab;
  587.       yyn = -yyn;
  588.       goto yyreduce;
  589.     }
  590.   else if (yyn == 0)
  591.     goto yyerrlab;
  592.  
  593.   if (yyn == YYFINAL)
  594.     YYACCEPT;
  595.  
  596.   /* Shift the lookahead token.  */
  597.  
  598. #if YYDEBUG != 0
  599.   if (yydebug)
  600.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  601. #endif
  602.  
  603.   /* Discard the token being shifted unless it is eof.  */
  604.   if (yychar != YYEOF)
  605.     yychar = YYEMPTY;
  606.  
  607.   *++yyvsp = yylval;
  608. #ifdef YYLSP_NEEDED
  609.   *++yylsp = yylloc;
  610. #endif
  611.  
  612.   /* count tokens shifted since error; after three, turn off error status.  */
  613.   if (yyerrstatus) yyerrstatus--;
  614.  
  615.   yystate = yyn;
  616.   goto yynewstate;
  617.  
  618. /* Do the default action for the current state.  */
  619. yydefault:
  620.  
  621.   yyn = yydefact[yystate];
  622.   if (yyn == 0)
  623.     goto yyerrlab;
  624.  
  625. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  626. yyreduce:
  627.   yylen = yyr2[yyn];
  628.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  629.  
  630. #if YYDEBUG != 0
  631.   if (yydebug)
  632.     {
  633.       int i;
  634.  
  635.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  636.            yyn, yyrline[yyn]);
  637.  
  638.       /* Print the symbols being reduced, and their result.  */
  639.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  640.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  641.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  642.     }
  643. #endif
  644.  
  645.  
  646.   switch (yyn) {
  647.  
  648. case 3:
  649. #line 26 "asm.y"
  650. { emit(yyvsp[0]); ;
  651.     break;}
  652. case 4:
  653. #line 29 "asm.y"
  654. { emit(yyvsp[-1]); emit(yyvsp[0]); ;
  655.     break;}
  656. case 5:
  657. #line 30 "asm.y"
  658. { emit(yyvsp[-1]); emit(yyvsp[0]); ;
  659.     break;}
  660. case 6:
  661. #line 31 "asm.y"
  662. { emit(yyvsp[-2]); emit(yyvsp[-1]);
  663.             emit(yyvsp[0]); ;
  664.     break;}
  665. case 7:
  666. #line 33 "asm.y"
  667. { if (!hidecnt) do_include(yyvsp[-1]); free(yyvsp[-1]); ;
  668.     break;}
  669. case 8:
  670. #line 34 "asm.y"
  671. { if (!hidecnt) do_include(yyvsp[-1]); free(yyvsp[-1]); ;
  672.     break;}
  673. case 9:
  674. #line 35 "asm.y"
  675. {
  676.         if (!hidecnt) do_define(yyvsp[-3], yyvsp[-1]); free(yyvsp[-3]); free(yyvsp[-1]); ;
  677.     break;}
  678. case 10:
  679. #line 37 "asm.y"
  680. {
  681.         if (!hidecnt) do_define(yyvsp[-3], yyvsp[-1]); free(yyvsp[-3]); free(yyvsp[-1]); ;
  682.     break;}
  683. case 11:
  684. #line 39 "asm.y"
  685. { do_ifdef(yyvsp[-1]); free(yyvsp[-1]); ;
  686.     break;}
  687. case 12:
  688. #line 40 "asm.y"
  689. { do_ifndef(yyvsp[-1]); free(yyvsp[-1]); ;
  690.     break;}
  691. case 13:
  692. #line 41 "asm.y"
  693. { do_else(); ;
  694.     break;}
  695. case 14:
  696. #line 42 "asm.y"
  697. { do_endif(); ;
  698.     break;}
  699. case 15:
  700. #line 45 "asm.y"
  701. { yyval = do_ops("", yyvsp[0], "", ""); free(yyvsp[0]); ;
  702.     break;}
  703. case 16:
  704. #line 47 "asm.y"
  705. { yyval = do_ops("", yyvsp[-2], yyvsp[-1], yyvsp[0]);
  706.              free(yyvsp[-2]); free(yyvsp[-1]); free(yyvsp[0]); ;
  707.     break;}
  708. case 17:
  709. #line 49 "asm.y"
  710. { yyval = do_ops(yyvsp[-2], yyvsp[0], "", ""); free(yyvsp[-2]); free(yyvsp[0]); ;
  711.     break;}
  712. case 18:
  713. #line 51 "asm.y"
  714. { yyval = do_ops(yyvsp[-4], yyvsp[-2], yyvsp[-1], yyvsp[0]);
  715.              free(yyvsp[-4]); free(yyvsp[-2]); free(yyvsp[-1]); free(yyvsp[0]);;
  716.     break;}
  717. case 19:
  718. #line 55 "asm.y"
  719. { yyval = yyvsp[0]; ;
  720.     break;}
  721. case 20:
  722. #line 56 "asm.y"
  723. { yyval = concat3(yyvsp[-2], ",", yyvsp[0]);
  724.                 free(yyvsp[-2]); free(yyvsp[0]); ;
  725.     break;}
  726. case 21:
  727. #line 60 "asm.y"
  728. { yyval = wordlookup(yyvsp[0]); free(yyvsp[0]); ;
  729.     break;}
  730. case 22:
  731. #line 63 "asm.y"
  732. { yyval = concat(yyvsp[-1], ":"); free(yyvsp[-1]); ;
  733.     break;}
  734. case 23:
  735. #line 65 "asm.y"
  736. {yyval = yyvsp[0]; ;
  737.     break;}
  738. case 24:
  739. #line 66 "asm.y"
  740. {yyval = immediate(yyvsp[0]); free(yyvsp[0]); ;
  741.     break;}
  742. case 25:
  743. #line 67 "asm.y"
  744. {yyval = indirect(yyvsp[-1]); free(yyvsp[-1]); ;
  745.     break;}
  746. case 26:
  747. #line 68 "asm.y"
  748. {yyval = postinc(yyvsp[-2]); free(yyvsp[-2]); ;
  749.     break;}
  750. case 27:
  751. #line 69 "asm.y"
  752. {yyval = predec(yyvsp[-1]); free(yyvsp[-1]); ;
  753.     break;}
  754. case 28:
  755. #line 70 "asm.y"
  756. {yyval = indexed(yyvsp[-3], yyvsp[-1]); free(yyvsp[-3]); free(yyvsp[-1]); ;
  757.     break;}
  758. case 29:
  759. #line 71 "asm.y"
  760. {yyval = sizedop(yyvsp[-2], yyvsp[0]); free(yyvsp[-2]); free(yyvsp[0]); ;
  761.     break;}
  762. case 30:
  763. #line 72 "asm.y"
  764. {yyval = twoindex(yyvsp[-5], yyvsp[-3], yyvsp[-1]);
  765.                 free(yyvsp[-5]); free(yyvsp[-3]); free(yyvsp[-1]); ;
  766.     break;}
  767. case 31:
  768. #line 74 "asm.y"
  769. {yyval = bitfield(yyvsp[-5], yyvsp[-3], yyvsp[-1]);
  770.             free(yyvsp[-5]); free(yyvsp[-3]); free(yyvsp[-1]); ;
  771.     break;}
  772. case 32:
  773. #line 78 "asm.y"
  774. { yyval = yyvsp[0]; ;
  775.     break;}
  776. case 33:
  777. #line 79 "asm.y"
  778. { yyval = concat3(yyvsp[-2], yyvsp[-1], yyvsp[0]); free(yyvsp[-2]); free(yyvsp[-1]); free(yyvsp[0]); ;
  779.     break;}
  780. case 34:
  781. #line 80 "asm.y"
  782. { yyval = concat("-", yyvsp[0]); free(yyvsp[0]); ;
  783.     break;}
  784. case 35:
  785. #line 82 "asm.y"
  786. {yyval = wordlookup(yyvsp[0]); free(yyvsp[0]); ;
  787.     break;}
  788. case 36:
  789. #line 83 "asm.y"
  790. {yyval = hexop(yyvsp[0]); free(yyvsp[0]);;
  791.     break;}
  792. case 37:
  793. #line 86 "asm.y"
  794. { yyval = strdup("+"); ;
  795.     break;}
  796. case 38:
  797. #line 87 "asm.y"
  798. { yyval = strdup("-"); ;
  799.     break;}
  800. case 39:
  801. #line 88 "asm.y"
  802. { yyval = strdup("*"); ;
  803.     break;}
  804. case 40:
  805. #line 89 "asm.y"
  806. { yyval = strdup("/"); ;
  807.     break;}
  808. }
  809.    /* the action file gets copied in in place of this dollarsign */
  810. #line 442 "bison.simple"
  811.  
  812.   yyvsp -= yylen;
  813.   yyssp -= yylen;
  814. #ifdef YYLSP_NEEDED
  815.   yylsp -= yylen;
  816. #endif
  817.  
  818. #if YYDEBUG != 0
  819.   if (yydebug)
  820.     {
  821.       short *ssp1 = yyss - 1;
  822.       fprintf (stderr, "state stack now");
  823.       while (ssp1 != yyssp)
  824.     fprintf (stderr, " %d", *++ssp1);
  825.       fprintf (stderr, "\n");
  826.     }
  827. #endif
  828.  
  829.   *++yyvsp = yyval;
  830.  
  831. #ifdef YYLSP_NEEDED
  832.   yylsp++;
  833.   if (yylen == 0)
  834.     {
  835.       yylsp->first_line = yylloc.first_line;
  836.       yylsp->first_column = yylloc.first_column;
  837.       yylsp->last_line = (yylsp-1)->last_line;
  838.       yylsp->last_column = (yylsp-1)->last_column;
  839.       yylsp->text = 0;
  840.     }
  841.   else
  842.     {
  843.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  844.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  845.     }
  846. #endif
  847.  
  848.   /* Now "shift" the result of the reduction.
  849.      Determine what state that goes to,
  850.      based on the state we popped back to
  851.      and the rule number reduced by.  */
  852.  
  853.   yyn = yyr1[yyn];
  854.  
  855.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  856.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  857.     yystate = yytable[yystate];
  858.   else
  859.     yystate = yydefgoto[yyn - YYNTBASE];
  860.  
  861.   goto yynewstate;
  862.  
  863. yyerrlab:   /* here on detecting error */
  864.  
  865.   if (! yyerrstatus)
  866.     /* If not already recovering from an error, report this error.  */
  867.     {
  868.       ++yynerrs;
  869.  
  870. #ifdef YYERROR_VERBOSE
  871.       yyn = yypact[yystate];
  872.  
  873.       if (yyn > YYFLAG && yyn < YYLAST)
  874.     {
  875.       int size = 0;
  876.       char *msg;
  877.       int x, count;
  878.  
  879.       count = 0;
  880.       for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  881.         if (yycheck[x + yyn] == x)
  882.           size += strlen(yytname[x]) + 15, count++;
  883.       msg = (char *) malloc(size + 15);
  884.       if (msg != 0)
  885.         {
  886.           strcpy(msg, "parse error");
  887.  
  888.           if (count < 5)
  889.         {
  890.           count = 0;
  891.           for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  892.             if (yycheck[x + yyn] == x)
  893.               {
  894.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  895.             strcat(msg, yytname[x]);
  896.             strcat(msg, "'");
  897.             count++;
  898.               }
  899.         }
  900.           yyerror(msg);
  901.           free(msg);
  902.         }
  903.       else
  904.         yyerror ("parse error; also virtual memory exceeded");
  905.     }
  906.       else
  907. #endif /* YYERROR_VERBOSE */
  908.     yyerror("parse error");
  909.     }
  910.  
  911.   goto yyerrlab1;
  912. yyerrlab1:   /* here on error raised explicitly by an action */
  913.  
  914.   if (yyerrstatus == 3)
  915.     {
  916.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  917.  
  918.       /* return failure if at end of input */
  919.       if (yychar == YYEOF)
  920.     YYABORT;
  921.  
  922. #if YYDEBUG != 0
  923.       if (yydebug)
  924.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  925. #endif
  926.  
  927.       yychar = YYEMPTY;
  928.     }
  929.  
  930.   /* Else will try to reuse lookahead token
  931.      after shifting the error token.  */
  932.  
  933.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  934.  
  935.   goto yyerrhandle;
  936.  
  937. yyerrdefault:  /* current state does not do anything special for the error token. */
  938.  
  939. #if 0
  940.   /* This is wrong; only states that explicitly want error tokens
  941.      should shift them.  */
  942.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  943.   if (yyn) goto yydefault;
  944. #endif
  945.  
  946. yyerrpop:   /* pop the current state because it cannot handle the error token */
  947.  
  948.   if (yyssp == yyss) YYABORT;
  949.   yyvsp--;
  950.   yystate = *--yyssp;
  951. #ifdef YYLSP_NEEDED
  952.   yylsp--;
  953. #endif
  954.  
  955. #if YYDEBUG != 0
  956.   if (yydebug)
  957.     {
  958.       short *ssp1 = yyss - 1;
  959.       fprintf (stderr, "Error: state stack now");
  960.       while (ssp1 != yyssp)
  961.     fprintf (stderr, " %d", *++ssp1);
  962.       fprintf (stderr, "\n");
  963.     }
  964. #endif
  965.  
  966. yyerrhandle:
  967.  
  968.   yyn = yypact[yystate];
  969.   if (yyn == YYFLAG)
  970.     goto yyerrdefault;
  971.  
  972.   yyn += YYTERROR;
  973.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  974.     goto yyerrdefault;
  975.  
  976.   yyn = yytable[yyn];
  977.   if (yyn < 0)
  978.     {
  979.       if (yyn == YYFLAG)
  980.     goto yyerrpop;
  981.       yyn = -yyn;
  982.       goto yyreduce;
  983.     }
  984.   else if (yyn == 0)
  985.     goto yyerrpop;
  986.  
  987.   if (yyn == YYFINAL)
  988.     YYACCEPT;
  989.  
  990. #if YYDEBUG != 0
  991.   if (yydebug)
  992.     fprintf(stderr, "Shifting error token, ");
  993. #endif
  994.  
  995.   *++yyvsp = yylval;
  996. #ifdef YYLSP_NEEDED
  997.   *++yylsp = yylloc;
  998. #endif
  999.  
  1000.   yystate = yyn;
  1001.   goto yynewstate;
  1002. }
  1003. #line 91 "asm.y"
  1004.  
  1005. #include <setjmp.h>
  1006.  
  1007. jmp_buf start;
  1008.  
  1009. #ifdef NATIVEATARI
  1010. #define STACK 32*1024L;
  1011. #ifdef LATTICE
  1012. long _STACK = STACK;
  1013. #endif
  1014. #ifdef __GNUC__
  1015. long _stksize = STACK;
  1016. #endif
  1017.  
  1018. static void
  1019. hit_return()
  1020. {
  1021.     printf("Hit return to continue\n");
  1022.     fflush(stdout);
  1023.     getchar();
  1024. }
  1025. #endif
  1026.  
  1027. void usage()
  1028. {
  1029.     fprintf(stderr, "Usage: asmtrans [-gas][-asm][-o outfile] infile\n");
  1030.     exit(2);
  1031. }
  1032.  
  1033. int errors = 0;
  1034.  
  1035. void
  1036. do_include(file)
  1037.     char *file;
  1038. {
  1039.     jmp_buf save;
  1040.     FILE *oldin, *f;
  1041.  
  1042.     f = fopen(file, "r");
  1043.     if (!f) {
  1044.         perror(file);
  1045.         return;
  1046.     }
  1047.     bcopy(start, save, sizeof(jmp_buf));
  1048.     oldin = infile;
  1049.     infile = f;
  1050.     setjmp(start);
  1051.     yyparse();
  1052.     fclose(f);
  1053.     infile = oldin;
  1054.     bcopy(save, start, sizeof(jmp_buf));
  1055.     longjmp(start,1);
  1056. }
  1057.  
  1058. /* set up initial definitions based on syntax type */
  1059.  
  1060. void
  1061. do_initial_defs()
  1062. {
  1063.     if (syntax == GAS) {
  1064.         do_define("fpiar", "fpi");
  1065.         do_define("XREF", ".globl");
  1066.         do_define("XDEF", ".globl");
  1067.         do_define("TEXT", ".text");
  1068.         do_define("DATA", ".data");
  1069.     /* gas doesn't have a .bss directive */
  1070.         do_define("BSS", ".data");
  1071.         do_define("END", "| END");
  1072.         do_define("dc.l", ".long");
  1073.         do_define("dc.w", ".word");
  1074.         do_define("dc.b", ".byte");
  1075.     } else if (syntax == ASM) {
  1076.         do_define("TEXT", "SECTION TEXT");
  1077.         do_define("DATA", "SECTION DATA");
  1078.         do_define("BSS", "SECTION BSS");
  1079.     }
  1080. }
  1081.  
  1082. int
  1083. main (argc, argv)
  1084.     int argc; char **argv;
  1085. {
  1086.     FILE *f;
  1087. #ifdef NATIVEATARI
  1088.     if (!argv[0] || !argv[0][0])    /* run from desktop? */
  1089.         atexit(hit_return);
  1090. #endif
  1091.     argv++;
  1092.     outfile = stdout;
  1093.  
  1094.     while (*argv) {
  1095.         if (!strcmp(*argv, "-o")) {
  1096.             argv++;
  1097.             if (*argv == 0) {
  1098.                 fprintf(stderr, "missing argument to -o\n");
  1099.                 usage();
  1100.             }
  1101.             f = fopen(*argv, "w");
  1102.             if (!f)
  1103.                 perror(*argv);
  1104.             else
  1105.                 outfile = f;
  1106.             argv++;
  1107.         } else if (!strcmp(*argv, "-gas")) {
  1108.             argv++;
  1109.             syntax = GAS;
  1110.         } else if (!strcmp(*argv, "-asm")) {
  1111.             argv++;
  1112.             syntax = ASM;
  1113.         } else if (!strcmp(*argv, "-purec")) {
  1114.             argv++;
  1115.             syntax = PUREC;
  1116.         } else if (!strncmp(*argv, "-D", 2)) {
  1117.             char *word, *defn;
  1118.             word = *argv+2;
  1119.             defn = index(word,'=');
  1120.             if (defn)
  1121.                 *defn++ = '\0';
  1122.             else
  1123.                 defn = "1";
  1124.             if (*word) do_define(word,defn);
  1125.             argv++;
  1126.         } else if (!strcmp(*argv, "--")) {
  1127.             argv++;
  1128.             break;
  1129.         } else {
  1130.             if (**argv == '-') {
  1131.                 fprintf(stderr, "unknown option: %s\n",
  1132.                     *argv);
  1133.                 usage();
  1134.             }
  1135.             break;
  1136.         }
  1137.     }
  1138.  
  1139.     do_initial_defs();
  1140.  
  1141.     if (*argv == 0) {
  1142.         setjmp(start);
  1143.         infile = stdin;
  1144.         yyparse();
  1145.     } else {
  1146.         while(*argv) {
  1147.         if (!(f = fopen(*argv, "r")))
  1148.             perror(*argv);
  1149.         else {
  1150.             infile = f;
  1151.             setjmp(start);
  1152.             yyparse();
  1153.             fclose(f);
  1154.         }
  1155.         argv++;
  1156.         }
  1157.     }
  1158.  
  1159.     if (ifstkptr != 0) {
  1160.         fputs("%ifdef without matching %endif\n", stderr);
  1161.         errors++;
  1162.     }
  1163.     return errors;
  1164. }
  1165.  
  1166. void
  1167. yyerror (s)  /* Called by yyparse on error */
  1168.      char *s;
  1169. {
  1170.     errors++;
  1171.     printf("%s\n", s);
  1172.     longjmp(start, 1);
  1173. }
  1174.  
  1175. void dbgmsg(s) char *s;
  1176. {
  1177.     fprintf(stderr, "%s\n", s);
  1178. }
  1179.